package com.sinven.controller;

import com.sinven.common.ActionResult;
import com.sinven.common.Pager;
import com.sinven.pojo.Environment;
import com.sinven.pojo.SinglePage;
import com.sinven.service.EnvService;
import com.sinven.service.SinglePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("school")
public class SchoolPageController {

    @Autowired
    private SinglePageService pageService;
    @Autowired
    private EnvService envService;
    @RequestMapping("/environment.html")
    public String showEnviroment(Model model, @RequestParam(value = "page",defaultValue = "1") Long page){
        Pager<Environment> pager = envService.queryPageData(page, 12);
        model.addAttribute("pager",pager);
        return "school/environment";
    }
    @RequestMapping("/feature.html")
    public String showFeature(Model model){
        SinglePage sp = pageService.queryPage("feature");
        model.addAttribute("page",sp);
        return "school/feature";
    }
    @RequestMapping("{page}.html")
    public String show( @PathVariable("page") String page,
                       Model model) {
        SinglePage sp = pageService.queryPage(page);
        model.addAttribute("page",sp);
        return  "singlepage";
    }



}
